package com.ruoyi.buss.report.service.impl;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.buss.report.mapper.QmcyCustJxyxyjbMapper;
import com.ruoyi.buss.qmcy.domain.QmcyCustZhjy;
import com.ruoyi.buss.report.domain.QmcyCustJxyxyjb;
import com.ruoyi.buss.report.service.IQmcyCustJxyxyjbService;
import com.ruoyi.system.api.model.LoginUser;

/**
 * 绩效营销业绩Service业务层处理
 * 
 * @author zjh
 * @date 2021-08-03
 */
@Service
public class QmcyCustJxyxyjbServiceImpl implements IQmcyCustJxyxyjbService 
{
    @Autowired
    private QmcyCustJxyxyjbMapper qmcyCustJxyxyjbMapper;

	public List<QmcyCustJxyxyjb> getQmcyCustJxyxyjInfo(QmcyCustJxyxyjb qmcyCustJxyxyjb, LoginUser userInfo) {
		String userId = userInfo.getSysUser().getUserName();
		List<QmcyCustJxyxyjb> doList = new ArrayList<QmcyCustJxyxyjb>();

		if (userInfo.getRoles().contains("admin") || userInfo.getRoles().contains("office")) {
			doList = qmcyCustJxyxyjbMapper.getQmcyCustJxyxyjInfoAll(qmcyCustJxyxyjb);
		} else if (userInfo.getRoles().contains("zhhz") || userInfo.getRoles().contains("common")) {
			// 支行行长，支行客户经理或者柜员，查询所属自己的客户
			qmcyCustJxyxyjb.setUserId(userId);
			doList = qmcyCustJxyxyjbMapper.getQmcyCustJxyxyjInfo(qmcyCustJxyxyjb);
		} else {
			return doList;
		}
		return doList;
	}
    
    /**
     * 查询绩效营销业绩
     * 
     * @param userId 绩效营销业绩ID
     * @return 绩效营销业绩
     */
    @Override
    public QmcyCustJxyxyjb selectQmcyCustJxyxyjbById(String userId)
    {
        return qmcyCustJxyxyjbMapper.selectQmcyCustJxyxyjbById(userId);
    }

    /**
     * 查询绩效营销业绩列表
     * 
     * @param qmcyCustJxyxyjb 绩效营销业绩
     * @return 绩效营销业绩
     */
    @Override
    public List<QmcyCustJxyxyjb> selectQmcyCustJxyxyjbList(QmcyCustJxyxyjb qmcyCustJxyxyjb)
    {
        return qmcyCustJxyxyjbMapper.selectQmcyCustJxyxyjbList(qmcyCustJxyxyjb);
    }

    /**
     * 新增绩效营销业绩
     * 
     * @param qmcyCustJxyxyjb 绩效营销业绩
     * @return 结果
     */
    @Override
    public int insertQmcyCustJxyxyjb(QmcyCustJxyxyjb qmcyCustJxyxyjb)
    {
        return qmcyCustJxyxyjbMapper.insertQmcyCustJxyxyjb(qmcyCustJxyxyjb);
    }

    /**
     * 修改绩效营销业绩
     * 
     * @param qmcyCustJxyxyjb 绩效营销业绩
     * @return 结果
     */
    @Override
    public int updateQmcyCustJxyxyjb(QmcyCustJxyxyjb qmcyCustJxyxyjb)
    {
        return qmcyCustJxyxyjbMapper.updateQmcyCustJxyxyjb(qmcyCustJxyxyjb);
    }

    /**
     * 批量删除绩效营销业绩
     * 
     * @param userIds 需要删除的绩效营销业绩ID
     * @return 结果
     */
    @Override
    public int deleteQmcyCustJxyxyjbByIds(String[] userIds)
    {
        return qmcyCustJxyxyjbMapper.deleteQmcyCustJxyxyjbByIds(userIds);
    }

    /**
     * 删除绩效营销业绩信息
     * 
     * @param userId 绩效营销业绩ID
     * @return 结果
     */
    @Override
    public int deleteQmcyCustJxyxyjbById(String userId)
    {
        return qmcyCustJxyxyjbMapper.deleteQmcyCustJxyxyjbById(userId);
    }
}
